-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: Browser will freeze when sync request is intercepted #32925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
|
Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the |
The routeHandler is executed but the request that goes to the server won't be modified req.headers["foo"] = "bar" The server will not get this since it's not resolved, but anything you console.log in the routeHandler will print in DevTools console |
|
Ok, I see the |
|
The second part of the fix (7b4f2e7) fixes a freezing issue when there's a sync request in cy.origin block The downside is cross-origin cookies most likely won't work in this case In cases where you must use |
|
Thanks for cross origin explanation. I'll have to look into it further. |
|
@alexsch01, I discussed this PR with the rest of the team and we are good with proceeding. We should skip adding the subscriptions entirely here so the |
|
@mschile I skipped adding the subscriptions entirely for sync requests and added the 2 warnings Let me know how that looks |
This issue happens when a synchronous request is intercepted and the
routeHandlerargument to cy.intercept is givenThe second part of this PR (prevent cross origin cookies from breaking sync requests)
Additional details
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?Note
Detects synchronous XMLHttpRequest calls and avoids intercepting or applying cross-origin cookie automation, preventing browser hangs.
runnerinjection: mark sync XHR viax-cypress-is-sync-requestinXMLHttpRequest.open; track_isSyncRequestand skip credentials signaling insendfor sync requests.proxy:x-cypress-is-sync-request, setreq.isSyncRequest.req.isSyncRequest: boolean.req.isSyncRequest, skip cross-origin cookie automation; emit warnings.net-stubbing: inInterceptedRequest.addDefaultSubscriptions, ifreq.isSyncRequest, warn and skip setting upcy.intercept()subscriptions (no interception).Written by Cursor Bugbot for commit 88c83e1. This will update automatically on new commits. Configure here.